package com.library_manage_system.view;

import java.awt.CardLayout;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;

import javax.swing.JButton;
import javax.swing.JPanel;

import com.library_manager_system.Book;
import com.library_manager_system.utils.LibraryDao;

public class SelectPanel {
	public JPanel selectPanel(final CardLayout cardLayout, final JPanel cardPanel,final ArrayList<Book> arraylist) {

		JPanel selectPanel = new JPanel();
		selectPanel.setLayout(new GridLayout(7, 1, 1, 1));

		JButton button1 = new JButton("图书资料录入");
		JButton button2 = new JButton("图书借出");
		JButton button3 = new JButton("图书归还");
		JButton button4 = new JButton("图书查找");
		JButton button5 = new JButton("图书资料修改");
		JButton button6 = new JButton("统计数据");
		JButton button7 = new JButton("退出程序");

		selectPanel.add(button1);
		selectPanel.add(button2);
		selectPanel.add(button3);
		selectPanel.add(button4);
		selectPanel.add(button5);
		selectPanel.add(button6);
		selectPanel.add(button7);

		button1.addActionListener(new ActionListener() {

			@Override
			public void actionPerformed(ActionEvent e) {
				// TODO Auto-generated method stub
				cardLayout.show(cardPanel, "loggingPanel");
			}
		});

		button2.addActionListener(new ActionListener() {

			@Override
			public void actionPerformed(ActionEvent e) {
				// TODO Auto-generated method stub
				cardLayout.show(cardPanel, "borrowBookPanel");
			}
		});

		button3.addActionListener(new ActionListener() {

			@Override
			public void actionPerformed(ActionEvent e) {
				// TODO Auto-generated method stub
				cardLayout.show(cardPanel, "returnboookPanel");
			}
		});

		button4.addActionListener(new ActionListener() {

			@Override
			public void actionPerformed(ActionEvent e) {
				// TODO Auto-generated method stub
				cardLayout.show(cardPanel, "findBookPanel");
			}
		});

		button5.addActionListener(new ActionListener() {

			@Override
			public void actionPerformed(ActionEvent e) {
				// TODO Auto-generated method stub
				cardLayout.show(cardPanel, "modifyBookPanel");
			}
		});

		button6.addActionListener(new ActionListener() {

			@Override
			public void actionPerformed(ActionEvent e) {
				// TODO Auto-generated method stub
				cardLayout.show(cardPanel, "staticsPanel");
			}
		});
		button7.addActionListener(new ActionListener() {

			@Override
			public void actionPerformed(ActionEvent e) {
				// TODO Auto-generated method stub
				LibraryDao.updateLibraryDao(arraylist,1);
				
				System.exit(0);
			}
		});
		return selectPanel;

	}

}
